<?php
require_once APP . '/application/admincontrollers/AdminAction.php';
require_once APP  . '/application/models/UserModel.php';

/**
 * 平台设置
 * @package admin
 */
class UserController extends AdminAction
{
    
    public function init()
    {
    }
	
    public function listAction()
    {
    	$nowp = $this->getParam ('nowp', 1);
        $per_page = 20;

        $image_obj = new UserModel($this->db);
        $result = $image_obj->fetchAll($nowp, $per_page);

        $this->view->list = $result['list'];
        $this->view->page = $result['page'];
    }
    
   
    public function resetAction()
    {
    	global $cfg;
    	$this->setAutoRender(false);
    	
    	$UserId = $this->getPost("UserId");
    	
    	$user = new UserModel($this->db);
    	$pwd = "123456";
    	$pwd = md5($cfg['slot'] . md5($pwd));
    	$user->change($UserId, array("password" => $pwd));
    	echo 'T';
    }
    
    public function logAction()
    {
    	$nowp = $this->getParam ('nowp', 1);
        $per_page = 25;

        $image_obj = new UserModel($this->db);
        $result = $image_obj->fetchLogAll($nowp, $per_page);

        $this->view->list = $result['list'];
        $this->view->page = $result['page'];
    }
}